<html>

	<head>
		<meta charset="UTF-8" />
		<title>R</title>
		<style>
			#box {
				border: 1px solid #999;
				border-collapse: collapse;
				margin: 0px;
				padding: 0px;
			}
			
			#box td {
				border: 1px solid #999;
				width: 19px;
				height: 19px;
			}
		</style>
	</head>
	<script>
	</script>

	<body>
		<table id="box">

		</table>
		<script src="step1.js">
			/*创建格式的JS代码*/
		</script>
		<script>
			//生产方块形状, 有7种基本形状. 
			createBlock();

			function createBlock() {
				var activeBlock = null;
				//生成一个0到6之间随机数 
				var t = Math.floor(Math.random() * 7);
				//7中图形，每种4个方块，每个方块水平和垂直坐标共8个坐标
				//以下坐标2个一对(0,4)代表第一个方块所处的格子为(第一行，第五列)
				var arr7 = "0,4,1,4,0,5,1,5;0,3,0,4,0,5,0,6;0,5,1,4,1,5,2,4;0,4,0,5,1,5,1,6;0,4,1,4,2,4,2,5;0,5,1,5,2,4,2,5;0,5,1,4,1,5,1,6"
				var arr = arr7.split(";")
				activeBlock = arr[t].split(","); //当前活动块（7个中的一个）
				for(var i = 0; i < 4; i++) {
					box.rows[activeBlock[i * 2]].cells[activeBlock[i * 2 + 1]].style.backgroundColor = "red";
				}
			}

			/*
			 * 
			 * 参数说明：
			 	arr7 = []
					arr7[0] = "0,4,1,4,0,5,1,5"; // O型也就是方块(行下标,列下标)
					arr7[1] = "0,3,0,4,0,5,0,6"; // i 型水平四个方块
					arr7[2] = "0,5,1,4,1,5,2,4"; // S型
					arr7[3] = "0,4,0,5,1,5,1,6"; // Z型
					arr7[4] = "0,4,1,4,2,4,2,5"; // L型
					arr7[5] = "0,5,1,5,2,4,2,5"; // J型
					arr7[6] = "0,5,1,4,1,5,1,6"; // T型
			 * 
			 * 
			 * */
		</script>
	</body>

</html>